import bcrypt from 'bcrypt'

try {
  let c1 = bcrypt.hashSync('123456', 10)
  let c2 = bcrypt.hashSync('123456', 10)
  let c3 = bcrypt.hashSync('123456', 10)

  console.log('c1', c1, 'c1的长度', c1.length); // $2b$10$DsLeFZUgjcphsPj0ZvLSKeXexKEuRcY74qU4ouO4gx7MvWEnRP9Dm c1的长度 60
  console.log('c2', c2, 'c2的长度', c2.length); // $2b$10$1fDmyxzLuXBH6YhNmVZYneWvgXiMtU/Ait41mbRn6lFYeDzOy.XAy c2的长度 60
  console.log('c3', c3, 'c3的长度', c3.length); // $2b$10$4mvmJhpOiIXPw9TsMUwejuu8VHB84e1s2aOtOB3S509KXIs2muL.K c3的长度 60


  // 检查密码/比较
  let r1 = bcrypt.compareSync('123456', c1)
  console.log('比较的结果：', r1); // true

  let r2 = bcrypt.compareSync('12345', c1)
  console.log('比较的结果：', r2); // false
} catch (error) {
  console.log('报错');
  console.log(error);
}
